/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/15
\**********************/
#include "LuaListHeader.h"

#define CObjPtr ((CListHeaderUI*)m_cobj)

namespace DuiLib {

int LuaListHeader::EstimateSize(LuaState *L)
{
    LuaStack args(L);
    SIZE szAvailable = LuaHelperNS::GetSize(args[2]);
    SIZE sz = CObjPtr->EstimateSize(szAvailable);
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

int LuaListHeader::SetPos(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    bool bNeedInvalidate = LuaHelperNS::GetBool(args[3], true);
    CObjPtr->SetPos(rc, bNeedInvalidate);
    return 0;
}

void LuaListHeader::SetScaleHeader(bool bIsScale)
{
    CObjPtr->SetScaleHeader(bIsScale);
}

bool LuaListHeader::IsScaleHeader()
{
    return CObjPtr->IsScaleHeader();
}

SDLUA_BEGIN_REGISTER(LuaListHeader, ListHeader, HorizontalLayout)
    SDLUA_REGISTER_FUN_LUA(LuaListHeader, EstimateSize, EstimateSize)
    SDLUA_REGISTER_FUN_LUA(LuaListHeader, SetPos, SetPos)
    SDLUA_REGISTER_FUN_CPP(LuaListHeader, SetScaleHeader, SetScaleHeader)
    SDLUA_REGISTER_FUN_CPP(LuaListHeader, IsScaleHeader, IsScaleHeader)
SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaListHeader, ListHeader)
SDLUA_END_UNREGISTER(ListHeader)

}

#undef CObjPtr